<?php
	session_start();

	if($_SESSION['uid']==""||$_SESSION['level']!=2){
		header("Location: ./exit.php");
		exit();
	}
	include('/php/tool/submitValidate.php');
	include('/php/tool/pdo.php');
	include('/php/class/public-data.class.php');
	include('/php/bll/PublicDataBLL.php');
    include('/php/class/student-information-register.class.php');
	include('/php/bll/StudentInformationRegisterBLL.php');
	
	//(int)$property= isset($_GET['property']) ? $_GET['property'] : 0;
	$grade= isset($_GET['grade']) ? $_GET['grade'] : 0;
	$major= isset($_GET['major']) ? $_GET['major'] : 0;
	$class= isset($_GET['class']) ? $_GET['class'] : 0;
	(int)$page = isset($_GET['page']) ? $_GET['page'] : 0;
	(int)$pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 20;
	$search = isset($_GET['search']) ? $_GET['search'] : '';

	/*if(!$apartmentBLL->apartmentListViewValidate($page,$pageSize,$property)){
		header("Location: http://www.baidu.com");
		exit();
	}*/
	$publicData=new PublicDataBLL();
	$studentInformationRegisterBLL=new StudentInformationRegisterBLL();//$_SESSION['uid']
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="lib/webuploader/0.1.5/webuploader.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>学生信息管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 学生管理 <span class="c-gray en">&gt;</span> 学生登记 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">

	<div class="text-c">
		<!--<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>-->
		<div class="cl pd-5 mybg-2 bk-gray">
			<span class="l">
                <span>
                    <div id="uploader" class="wu-example">
                        <!--用来存放文件信息-->
                        <div id="thelist" class="uploader-list"></div>
                        <div class="btns">
                            <div id="picker">批量导入</div>
                            <button id="ctlBtn" class="btn btn-default">开始上传</button>
                        </div>
                    </div>
                </span>
            </span>
            <span class="l ml-5">
				<button onclick="addStudentView()" class="btn btn-primary radius">添加学生</button>
				<button onclick="removeStudentChecked()" class="btn btn-danger radius">移除选中</button>
			</span>
			<span class="r">
				<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>
			</span>
		</div>
	</div>

	<div class="mt-10">
		<form action="student-information-register.php" method="get" class="form-horizontal mybg-2 bk-gray pt-5 pb-5">
			<div class="row cl mb-5">
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">年级：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<select id="grade_select" name="grade" class="select" size="1" style="height:31px">
					<option value="0">所有</option>
						<?php
							//获取年级列表
							$gradeList=$publicData->getInstructorGradeList($_SESSION['uid']);
							foreach($gradeList as $myGrade){
								if($myGrade['grade']==$grade){
									echo '<option value="'.$myGrade['grade'].'" selected="">'.$myGrade['grade'].'</option>';
								}else{
									echo '<option value="'.$myGrade['grade'].'">'.$myGrade['grade'].'</option>';
								}
							}
						?>
					</select>
				</div>
				<label class="form-label col-xs-1" style="width:120px;margin:0;padding:0;line-height:31px;">专业：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<select id="major_select" name="major" class="select" size="1" style="height:31px">
					<option value="0">所有</option>
						<?php
							//获取专业列表
							$majorList=$publicData->getInstructorMajorList($_SESSION['uid']);
							foreach($majorList as $myMajor){
								if($myMajor['major_id']==$major){
									echo '<option value="'.$myMajor['major_id'].'" selected="">'.$myMajor['major_name'].'</option>';
								}else{
									echo '<option value="'.$myMajor['major_id'].'">'.$myMajor['major_name'].'</option>';
								}
							}
						?>
					</select>
				</div>
			</div>
			<div class="row cl mb-5">
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">班级：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<select id="grade_select" name="class" class="select" size="1" style="height:31px">
					<option value="0">所有</option>
						<?php
							//获取班级列表
							$classList=$publicData->getInstructorClassList($_SESSION['uid']);
							foreach($classList as $myClass){
								if($myClass['class']==$class){
									echo '<option value="'.$myClass['class'].'" selected="">'.$myClass['class'].'</option>';
								}else{
									echo '<option value="'.$myClass['class'].'">'.$myClass['class'].'</option>';
								}
							}
						?>
					</select>
				</div>
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">姓名或学号：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<input  id="search" name="search" type="text" class="input-text" style="width:100%"  value="<?php echo $search;?>" placeholder="">
					<label id="search-error" class="error valid" for="search" style="display:none;">这是必填字段</label>
				</div>
				<button id="btn-search"  class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 查找</button>
			</div>
		</form>
	</div>

	<div class="mt-20">
			<table class="table table-border table-bordered table-hover table-bg">
					<thead>
						<tr>
							<th colspan="9" scope="col">学生信息管理</th>
						</tr>
						<tr class="text-c">
							<th><input type="checkbox" value="" name=""></th>
							<th>学号</th>
							<th>姓名</th>
							<th>性别</th>
							<th>年级</th>
							<th>专业</th>
							<th>班级</th>
							<th>联系电话</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
					<?php //$_SESSION['uid']
						$result=$studentInformationRegisterBLL->getStudentInformationList($_SESSION['uid'],$grade,$major,$class,$page,$pageSize,$search);
						$studentList=$result['studentList'];
						$pageMax=$result['count'];
						foreach($studentList as $student){
							echo '<tr class="text-c">
							<td width="25"><input type="checkbox" value="'.$student['student_id'].'" name="chekbox_student"></td>
							<td class="student_id">'.$student['student_id'].'</td>
							<td class="name">'.$student['name'].'</td>
							<td class="gender">'.($student['gender']==1?'女':'男').'</td>
							<td class="gender_id" style="display:none">'.$student['gender'].'</td>
							<td class="grade">'.$student['grade'].'</td>
							<td class="major_id" style="display:none">'.$student['major_id'].'</td>
							<td class="major_name">'.$student['major_name'].'</td>
							<td class="class">'.$student['class'].'</td>
							<td class="phone_number">'.$student['phone_number'].'</td>
							<td width="50"><a title="编辑" href="javascript:;" onClick="editStudentInfoView(this)" style="text-decoration:none">
							<i class="Hui-iconfont">&#xe6df;</i></a>
							<a title="删除" href="javascript:;" onclick="removeStudent(\''.$student['student_id'].'\')" class="ml-5" style="text-decoration:none">
							<i class="Hui-iconfont">&#xe6e2;</i></a></td></tr>';
						}
					?>
					</tbody>
				</table>
	</div>
	<div class="modal-footer">
		<a class="btn" href="<?php echo './student-information-register.php?&grade='.$grade.'&major='.$major.'&class='.$class.'&page='.($page-1>0?$page-1:0).'&pageSize='.$pageSize.'&search='.$search; ?>">上一页</a>
			<span><select  id="student_page" name="page" class="btn">
				<?php
					if($pageMax>0){
						for($i=0;$i<$pageMax;$i++){
							if($i==$page){//selected=""
								echo '<option value="'.$i.'" selected="selected">'.($i+1).'</option>';
							}else{
								echo '<option value="'.$i.'" ">'.($i+1).'</option>';
							}
						}
					}else{
						echo '<option value="0">1</option>';
					}
				?>
			</select>
		</span>
		<a class="btn" href="<?php echo './student-information-register.php?&grade='.$grade.'&major='.$major.'&class='.$class.'&page='.($page+1<$pageMax?$page+1:$page).'&pageSize='.$pageSize.'&search='.$search; ?>">下一页</a>
	</div>
</div>
<!--遮罩层,添加学生信息-->
    <div id="modal-add-student" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width:80%;">
			<div class="modal-content radius">
				<div class="modal-header">
					<h3 class="modal-title">添加学生信息</h3>
					<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
				</div>
				<div class="modal-body">
					<div class="mt-10">
						<div class="form-horizontal mybg-2 bk-gray pt-5 pb-5" id="form-article-add">
							<div class="row cl mb-5">
								<label class="form-label col-xs-4 col-sm-2">学号：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <input id="student_id" value="" class="input-text col-xs-8 col-sm-4" type="text">
									<label id="student_id-error" class="error valid" for="student_id" style="display:none;">输入不符合要求</label>
								</div>
								<label class="form-label col-xs-4 col-sm-2">姓名：</label>
								<div class="formControls col-xs-8 col-sm-3">
									<input id="student_name" type="text" class="input-text col-xs-8 col-sm-4">
									<label id="student_name-error" class="error valid" for="student_name" style="display:none;">输入不符合要求</label>
								</div>
							</div>

							<div class="row cl mb-5">
                                <label class="form-label col-xs-4 col-sm-2">性别：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <select id="student_gender" name="add_major_select" class="select" size="1" style="height:31px">
										<option value="1">女</option>
                                        <option value="2">男</option>
									</select>
								</div>
                                <label class="form-label col-xs-4 col-sm-2">联系电话：</label>
								<div class="formControls col-xs-8 col-sm-3">
									<input id="student_phone" type="text" class="input-text col-xs-8 col-sm-4">
									<label id="student_phone-error" class="error valid" for="student_phone" style="display:none;">输入不符合要求</label>
								</div>
							</div>

                            <div class="row cl mb-5">
                                <label class="form-label col-xs-4 col-sm-2">年级：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <select id="student_grade" name="student_grade" class="select" size="1" style="height:31px">
									<?php
										date_default_timezone_set("PRC");
										$grade_min=(int)(date('Y'))-8;
										$grade_now=(int)(date('Y'));
										for($i=$grade_min;$i<$grade_now;$i++){
											echo '<option value="'.$i.'">'.$i.'</option>';
										}
										echo '<option value="'.$i.'" selected="">'.$i.'</option>'
									?>
									</select>
								</div>
                                <label class="form-label col-xs-4 col-sm-2">专业：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <select id="student_major" name="student_major" class="select" size="1" style="height:31px">
									<?php
										foreach($majorList as $myMajor){
											echo '<option value="'.$myMajor['major_id'].'">'.$myMajor['major_name'].'</option>';
										}
									?>
									</select>
								</div>
							</div>
							<div class="row cl mb-5">
                                <label class="form-label col-xs-4 col-sm-2">班级：</label>
								<div class="formControls col-xs-8 col-sm-3">
									<input id="class" type="text" class="input-text col-xs-8 col-sm-4">
									<label id="class-error" class="error valid" for="class" style="display:none;">输入不符合要求</label>
								</div>
							</div>
							</div>
						</div>
						<div class="modal-footer mybg-2">
							<button id="add" onclick="addStudentSubmit()" class="btn btn-primary radius">添加</button>
							<button class="btn btn-default radius" data-dismiss="modal" aria-hidden="true">取消</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<!--遮罩层,更新学生信息-->
<div id="modal-update-student" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width:80%;">
			<div class="modal-content radius">
				<div class="modal-header">
					<h3 class="modal-title">编辑学生信息</h3>
					<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
				</div>
				<div class="modal-body">
					<div class="mt-10">
						<div class="form-horizontal mybg-2 bk-gray pt-5 pb-5" id="form-article-add">
							<div class="row cl mb-5">
								<label class="form-label col-xs-4 col-sm-2">学号：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <input id="update_student_id" value="" disabled="disabled" class="input-text col-xs-8 col-sm-4" type="text">
									<label id="update_student_id-error" class="error valid" for="update_student_id" style="display:none;">输入不符合要求</label>
								</div>
								<label class="form-label col-xs-4 col-sm-2">姓名：</label>
								<div class="formControls col-xs-8 col-sm-3">
									<input id="update_student_name" type="text" class="input-text col-xs-8 col-sm-4">
								</div>
							</div>

							<div class="row cl mb-5">
                                <label class="form-label col-xs-4 col-sm-2">性别：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <select id="update_gender_select" name="add_major_select" class="select" size="1" style="height:31px">
										<option value="1">女</option>
                                        <option value="2">男</option>
									</select>
								</div>
                                <label class="form-label col-xs-4 col-sm-2">联系电话：</label>
								<div class="formControls col-xs-8 col-sm-3">
									<input id="update_student_phone" type="text" class="input-text col-xs-8 col-sm-4">
									<label id="update_student_phone-error" class="error valid" for="update_student_phone" style="display:none;">输入不符合要求</label>
								</div>
							</div>

                            <div class="row cl mb-5">
                                <label class="form-label col-xs-4 col-sm-2">年级：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <select id="update_grade_select" name="major_select" class="select" size="1" style="height:31px">
									<?php
										//date_default_timezone_set("PRC");
										$grade_min=(int)(date('Y'))-8;
										$grade_now=(int)(date('Y'));
										for($i=$grade_min;$i<$grade_now;$i++){
											echo '<option value="'.$i.'">'.$i.'</option>';
										}
										echo '<option value="'.$i.'" selected="">'.$i.'</option>'
									?>
									</select>
								</div>
                                <label class="form-label col-xs-4 col-sm-2">专业：</label>
								<div class="formControls col-xs-8 col-sm-3">
                                    <select id="update_major_select" name="major_select" class="select" size="1" style="height:31px">
									<?php
										//$gradeMajorList
										foreach($majorList as $myMajor){
											echo '<option value="'.$myMajor['major_id'].'">'.$myMajor['major_name'].'</option>';
										}
									?>
									</select>
								</div>
							</div>
							<div class="row cl mb-5">
                                <label class="form-label col-xs-4 col-sm-2">班级：</label>
								<div class="formControls col-xs-8 col-sm-3">
									<input id="update_class" type="text" class="input-text col-xs-8 col-sm-4">
									<label id="update_class-error" class="error valid" for="update_class" style="display:none;">输入不符合要求</label>
								</div>
							</div>
							</div>
						</div>
						<div class="modal-footer mybg-2">
							<button onclick="editStudentInfo()" class="btn btn-primary radius">保存</button>
							<button class="btn btn-default radius" data-dismiss="modal" aria-hidden="true">取消</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="scripts/students-information-register.jquery.js"></script>
</body>
</html>